from src.app import app, db

with app.app_context():
    try:
        # 删除所有表
        db.drop_all()
        print("已删除所有表")
        
        # 创建所有表
        db.create_all()
        print("已创建所有表")
        
    except Exception as e:
        print(f"数据库初始化失败: {e}")
        import traceback
        traceback.print_exc()